package wyh.mapper;

import org.apache.ibatis.annotations.*;
import wyh.pojo.Escort;
import wyh.pojo.Patient;

import java.util.List;

/**
 * -- 创建 escortinfo 陪诊人员表
 * CREATE TABLE escortinfo
 * (
 * escortId                 INT PRIMARY KEY AUTO_INCREMENT, -- 陪诊人员唯一标识
 * name                     VARCHAR(255) NOT NULL,          -- 陪诊人员姓名
 * gender                   VARCHAR(10),                    -- 陪诊人员性别
 * age                      INT,                            -- 陪诊人员年龄
 * contactNumber            VARCHAR(20)  NOT NULL,          -- 陪诊人员联系电话
 * qualificationCertificate VARCHAR(50),                    -- 陪诊人员资质证书编号
 * hireDate                 DATE                            -- 陪诊人员入职日期
 * );
 */

@Mapper
public interface EscortMapper {

    // 根据姓名模糊查询信息
    @Select("SELECT * FROM escortinfo WHERE name LIKE CONCAT('%', #{name}, '%')")
    List<Escort> MappergetByNameLike(String name);

    @Select("select * from escortinfo")
    List<Escort> MappergetAll();

    @Update("update escortinfo set name=#{name} , gender=#{gender}, age=#{age}, contactNumber=#{contactNumber} , qualificationCertificate=#{qualificationCertificate}, hireDate=#{hireDate}  where escortId=#{escortId}")
    int MapperupdateUserById(Escort escort);

    @Insert("insert into escortinfo (name, gender, age, contactNumber, qualificationCertificate, hireDate) values (#{name}, #{gender}, #{age}, #{contactNumber}, #{qualificationCertificate}, #{hireDate})")
    int MapperaddUser(Escort escort);

    @Delete("DELETE FROM escortinfo WHERE escortId = #{escortId}")
    int MapperdeleteById(int escortId);

    @Select("SELECT * FROM escortinfo WHERE escortId = #{escortId}")
    Escort MappergetById(int escortId);
}
